/**
 *
 */
package org.xshop.service.impl;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.xshop.service.ISysDicService;
import org.xshop.service.ISysParamService;

import top.ibase4j.core.util.DataUtil;
import top.ibase4j.core.util.InstanceUtil;

/**
 *
 * @author ShenHuaJie
 * @version 2018年3月4日 下午7:16:19
 */
@Service
public class SysService {
    @Autowired
    private ISysParamService sysParamService;
    @Autowired
    private ISysDicService sysDicService;

    public String getSysParam(String key) {
        Object result = sysParamService.getValue(key);
        return (String)result;
    }

    public String getSysParam(String key, String defaultValue) {
        Object result = sysParamService.getValue(key);
        if (DataUtil.isEmpty(result)) {
            return defaultValue;
        }
        return (String)result;
    }

    public Map<?, ?> getDic(String type) {
        Map<String, Object> map = InstanceUtil.newHashMap("type", type);
        Map<?, ?> result = sysDicService.queryDicByTypeMap(map);
        return result;
    }
}
